/*    */ package com.zimbra.cs.account.ldap.upgrade;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.Cos;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Entry.EntryType;
/*    */ import com.zimbra.cs.account.ldap.LdapProv;
/*    */ import com.zimbra.cs.ldap.LdapClient;
/*    */ import com.zimbra.cs.ldap.LdapServerType;
/*    */ import com.zimbra.cs.ldap.LdapUsage;
/*    */ import com.zimbra.cs.ldap.ZLdapContext;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class BUG_65070
/*    */   extends UpgradeOp
/*    */ {
/*    */   private static final String ATTR_NAME = "zimbraPrefHtmlEditorDefaultFontFamily";
/*    */   private static final String OLD_VALUE = "Times New Roman";
/*    */   private static final String NEW_VALUE = "times new roman, new york, times, serif";
/*    */   
/*    */   void doUpgrade()
/*    */     throws ServiceException
/*    */   {
/* 41 */     ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
/*    */     try {
/* 43 */       doAllCos(zlc);
/*    */     } finally {
/* 45 */       LdapClient.closeContext(zlc);
/*    */     }
/*    */   }
/*    */   
/*    */   Description getDescription()
/*    */   {
/* 51 */     return new Description(this, new String[] { "zimbraPrefHtmlEditorDefaultFontFamily" }, new Entry.EntryType[] { Entry.EntryType.COS }, "Times New Roman", "times new roman, new york, times, serif", String.format("Upgrade attribute %s on all cos from \"%s\" to \"%s\"", new Object[] { "zimbraPrefHtmlEditorDefaultFontFamily", "Times New Roman", "times new roman, new york, times, serif" }));
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   private void doEntry(ZLdapContext zlc, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 61 */     String entryName = entry.getLabel();
/*    */     
/* 63 */     this.printer.println();
/* 64 */     this.printer.println("------------------------------");
/* 65 */     this.printer.println("Checking zimbraPrefHtmlEditorDefaultFontFamily on " + entryName);
/*    */     
/* 67 */     String curValue = entry.getAttr("zimbraPrefHtmlEditorDefaultFontFamily", false);
/* 68 */     if ("Times New Roman".equals(curValue)) {
/* 69 */       this.printer.println(String.format("    Changing %s on cos %s from \"%s\" to \"%s\"", new Object[] { "zimbraPrefHtmlEditorDefaultFontFamily", entryName, curValue, "times new roman, new york, times, serif" }));
/*    */       
/*    */ 
/*    */ 
/* 73 */       Map<String, Object> attr = new HashMap();
/* 74 */       attr.put("zimbraPrefHtmlEditorDefaultFontFamily", "times new roman, new york, times, serif");
/*    */       try {
/* 76 */         modifyAttrs(zlc, entry, attr);
/*    */       }
/*    */       catch (ServiceException e) {
/* 79 */         this.printer.println("Caught ServiceException while modifying " + entryName + " attribute " + attr);
/* 80 */         this.printer.printStackTrace(e);
/*    */       }
/*    */     } else {
/* 83 */       this.printer.println(String.format("    Current value of %s on cos %s is \"%s\" - not changed", new Object[] { "zimbraPrefHtmlEditorDefaultFontFamily", entryName, curValue }));
/*    */     }
/*    */   }
/*    */   
/*    */   private void doAllCos(ZLdapContext zlc)
/*    */     throws ServiceException
/*    */   {
/* 90 */     List<Cos> coses = this.prov.getAllCos();
/* 91 */     for (Cos cos : coses) {
/* 92 */       doEntry(zlc, cos);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/upgrade/BUG_65070.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */